package com.yxqz.scz.rabbitmq;

import com.yxqz.scz.rabbitmq.config.RabbitmqConfig;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * @author 鱼香茄子
 * @data 2021/10/26
 * springboot结合 topic方式
 * @SpringBootTest(classes = Application.class) 测试的时候，java包和测试包路径不一致需要配置aclasses
 */

@SpringBootTest()
@RunWith(SpringRunner.class)
public class Producer05_springboot_topics {


    //org.springframework.amqp.rabbit.core;
    @Autowired
    RabbitTemplate rabbitTemplate;


    /**
     * 使用 rabbitTemplat发送邮件队列 消息
     */
    @Test
    public  void  test1() {
        String message = "我在用spring整合，这里是生产者哦";
        /*
         * 交换机
         * routingKey
         * 消息内容
         */
            rabbitTemplate.convertAndSend(RabbitmqConfig.EXCHANGE_TOPICS_INFORM,"inform.email",message);
    }




}

